<template>
    <div class="log_box">
        <p class="log_bntx"  >{{ bntx_text }}</p>
        <div class="log_conter" v-for="(item,index) in  History_log" :key="index">
        {{index+1}}. {{ item.name }} {{item.title }}<span class="time"  >{{ item.time }}</span>
        </div>
        <div class="log_conter" v-for="(item,index) in  mode_names"  :key="index">
            <span class="texts nm">{{ item.name }} {{item.title }}</span><span class="time"  >{{ item.time }}</span>
        </div>
    </div>
    
  </template>
 <script setup>
 import { useRouter,useRoute,} from "vue-router";
 import moment from 'moment'
 import {
   $fullUrl,
   formatDate,
   $banseUrl,
   $check_action,
 } from "@/utils/utils.js";
 import { $post, $get } from "@/api/Api.js";
 import { Picture } from "@element-plus/icons-vue";
 import { ElMessage } from "element-plus";
 import { ref, watch, computed, onMounted } from "vue";
 import storageHelper from "@/libs/StorageHelper";
 let router = useRouter();
 let route = useRoute();
 let user_group = storageHelper.getGroupValue();
 let mode_names = ref([]);
 let History_log = ref([]);
 let bntx_text = ref('操作日志');
 let uesr_names = ref('');
 let showRentPrise = ref(true);
    onMounted(()=>{
       let data_hory =  localStorage.getItem('log_msg');
        History_log.value = data_hory ? JSON.parse(data_hory) : []
        // if (user_group==='管理员') {
        //   let data_hory =  localStorage.getItem('log_msg');
        // History_log.value = data_hory ? JSON.parse(data_hory) : []
        // }
        // else{
        //   localStorage.removeItem('log_msg')
 
        // }
        // if(user_group==='商城用户'){
        //   let data_hory =  localStorage.getItem('log_msg');
        // History_log.value = data_hory ? JSON.parse(data_hory) : []
        // }else{
        //   localStorage.removeItem('log_msg')
 
        // }
        // if(user_group==='卖家'){
        //   let data_hory =  localStorage.getItem('log_msg');
        //   History_log.value = data_hory ? JSON.parse(data_hory) : []
        // }
        // else{
        //   localStorage.removeItem('log_msg')
        
        // }  
      console.log(History_log.value)
    })

// watch(()=>
//   router.currentRoute.value,
//   (newValue) => {
//       const stamp = new Date()
//       let logs = moment(stamp).format('YYYY-MM-DD HH:mm:ss')
//       console.log(user_group)
//     console.log(route.meta.title)
//       //存入展示数组
//       if(route.meta.title!==undefined){
//         //mode_names.value.push(user_group+'--'+route.meta.title+' '+logs)
//         mode_names.value.push({
//           name:user_group,
//           title:route.meta.title,
//           time:logs,
//         })
//         //本地储存
//         localStorage.setItem('log_msg',JSON.stringify(mode_names.value))
//       }     
//   },{immediate: true,deep: true}
// )


  </script>
  
  <style  scoped lang='less'>
      .log_box{
       overflow-y: auto;
        height: 560px;
        .log_bntx{
          height: 40px;
          text-align: center;
          font-size: 18px;
          font-weight: 700;
        }
       }
      .log_conter{
        width: 80%;
        color: #141414;
        line-height: 30px;
        // position: absolute;
       
      }
      .time{
        display: inline-block;
        float: right;
        left: 10px;
        font-size: 14px;
      }
      .hs{
        width: 220px;
      }
  
  </style>